closed form of generating function